<template>
    <div class="newsinfo-container">
        <h1 class="title">{{newsInfo.title}}</h1>
        <p class="subTitle">
            <span>发表时间：{{newsInfo.add_time |dataFormat}}</span>
            <span>浏览量：{{newsInfo.click}}次</span>
        </p>
        <hr/>
        <div class="content" v-html="newsInfo.content"></div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
    import comment from '../subcomponents/Comment.vue'
    export default {
        name: "NewsInfo",
        data(){
            return{
                id:this.$route.params.id,
                newsInfo:{}
            }
        },
        created(){
          this.getNewsInfo();
        },
        methods:{
            getNewsInfo(){
                this.$http.get('api/getnew/'+this.id).then(result=>{
                    console.log(result.body.message[0]);
                    this.newsInfo=result.body.message[0];
                })
            }
        },
        components:{
            "comment-box":comment
        }
    }
</script>

<style>
    .newsinfo-container{
        padding: 0 4px;
    }
    .newsinfo-container .title{
        text-align: center;
        font-size: 16px;
        margin: 15px 0px;
        color: red;
    }
    .newsinfo-container .subTitle{
        font-size: 12px;
        color: #22a6ff;
        display: flex;
        justify-content: space-between;
    }
    .newsinfo-container .content img{
        width: 100%;
    }

</style>